package net.wyy.ssoclient.config;

import net.wyy.ssoclient.interceptor.LoginInterceptor;
import net.wyy.ssoclient.interceptor.TokenLoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * Created by Enzo Cotter on 2019/11/21.
 */
@Configuration
public class MvcConfig extends WebMvcConfigurationSupport {

    @Autowired
    private LoginInterceptor loginInterceptor;
    @Autowired
    private TokenLoginInterceptor tokenLoginInterceptor;

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenLoginInterceptor).addPathPatterns("/**").excludePathPatterns("/logout");
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**").excludePathPatterns("logout");
        super.addInterceptors(registry);
    }
}
